package com.cg.managesystem.service.impl;

import com.cg.managesystem.entity.Repair;
import com.cg.managesystem.mapper.RepairMapper;
import com.cg.managesystem.service.RepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created on 2019/8/13 by Tinchi
 **/
@Service
public class RepairServiceImpl implements RepairService {
    @Autowired
    private RepairMapper repairMapper;
    @Override
    public List<Repair> findAllRepairs() {
        return repairMapper.selectAll();
    }

    @Override
    public int addRepair(Repair repair) {
        return repairMapper.insert(repair);
    }

    @Override
    public int deleteRepairById(String id) {
        return repairMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateRepairById(Repair record) {
        return repairMapper.updateByPrimaryKey(record);
    }

    @Override
    public Repair selectRepairById(String id) {
        return repairMapper.selectByPrimaryKey(id);
    }

    //  根据订单id查询保修订单
    @Override
    public Repair selectByRepairId(String id) {
        return repairMapper.selectByRepairId(id);
    }

    //  根据用户id查询保修订单
    @Override
    public Repair selectByUserId(Integer uid) {
        return repairMapper.selectByUserId(uid);
    }

    //  根据维修工人查询报修订单
    @Override
    public List<Repair> selectByWorkerId(String worker) {
        return repairMapper.selectByWorkerId(worker);
    }

    //  根据保修的开始时间查询保修订单
    @Override
    public List<Repair> selectByStarttime(String starttime) {
        return repairMapper.selectByStarttime(starttime);
    }

}
